home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / apport / package-hooks / source_xorg.py < prev    next >
Encoding:
Python Source  |  2009-03-29  |  4.4 KB  |  150 lines

  1. #!/usr/bin/python
  2.  
  3. '''Xorg Apport interface
  4.  
  5. Copyright (C) 2007, 2008 Canonical Ltd.
  6. Author: Bryce Harrington <bryce.harrington@ubuntu.com>
  7.  
  8. This program is free software; you can redistribute it and/or modify it
  9. under the terms of the GNU General Public License as published by the
  10. Free Software Foundation; either version 2 of the License, or (at your
  11. option) any later version.  See http://www.gnu.org/copyleft/gpl.html for
  12. the full text of the license.
  13. '''
  14.  
  15. # TODO:
  16. #  - Create some general purpose routines (see source_network-manager.py)
  17. #  - Parse files to generate system_environment more concisely
  18. #  - Trim lshal output to just required info
  19.  
  20. import os.path
  21. import subprocess
  22.  
  23. def installed_version(pkg):
  24.     script = subprocess.Popen(['apt-cache', 'policy', pkg], stdout=subprocess.PIPE)
  25.     output = script.communicate()[0]
  26.     return output.split('\n')[1].replace("Installed: ", "")
  27.  
  28. def add_info(report):
  29.     # Build System Environment
  30.     report['system']      = " distro:             Ubuntu\n"
  31.     try:
  32.         script = subprocess.Popen(['uname', '-m'], stdout=subprocess.PIPE)
  33.         report['system'] += " architecture:       " + script.communicate()[0]
  34.     except OSError:
  35.         pass
  36.     try:
  37.         script = subprocess.Popen(['uname', '-r'], stdout=subprocess.PIPE)
  38.         report['system'] += " kernel:             " + script.communicate()[0]
  39.     except OSError:
  40.         pass
  41.     try:
  42.         report['system'] += " xserver-xorg:     " + installed_version('xserver-xorg') + "\n"
  43.     except OSError:
  44.         pass
  45.     try:
  46.         report['system'] += " mesa:             " + installed_version('libgl1-mesa-glx') + "\n"
  47.     except OSError:
  48.         pass
  49.     try:
  50.         report['system'] += " libdrm:           " + installed_version('libdrm2') + "\n"
  51.     except OSError:
  52.         pass
  53.     try:
  54.         report['system'] += " -intel:           " + installed_version('xserver-xorg-video-intel') + "\n"
  55.     except OSError:
  56.         pass
  57.     try:
  58.         report['system'] += " -ati:             " + installed_version('xserver-xorg-video-ati') + "\n"
  59.     except OSError:
  60.         pass
  61.  
  62.     try:
  63.         report['XorgConf'] = open('/etc/X11/xorg.conf').read()
  64.     except IOError:
  65.         pass
  66.  
  67.     try:
  68.         report['XorgLog']  = open('/var/log/Xorg.0.log').read()
  69.     except IOError:
  70.         pass
  71.  
  72.     try:
  73.         report['XorgLogOld']  = open('/var/log/Xorg.0.log.old').read()
  74.     except IOError:
  75.         pass
  76.  
  77.     try:
  78.         report['ProcVersion']  = open('/proc/version').read()
  79.     except IOError:
  80.         pass
  81.  
  82.     try:
  83.         script = subprocess.Popen(['lspci', '-vvnn'], stdout=subprocess.PIPE)
  84.         report['LsPci'] = script.communicate()[0]
  85.     except OSError:
  86.         pass
  87.  
  88.     try:
  89.         script = subprocess.Popen(['lshal'], stdout=subprocess.PIPE)
  90.         report['LsHal'] = script.communicate()[0]
  91.     except OSError:
  92.         pass
  93.  
  94.     try:
  95.         script = subprocess.Popen(['lsmod'], stdout=subprocess.PIPE)
  96.         report['LsMod'] = script.communicate()[0]
  97.     except OSError:
  98.         pass
  99.  
  100.     try:
  101.         script = subprocess.Popen(['grep', 'fglrx', '/var/log/kern.log', '/proc/modules'], stdout=subprocess.PIPE)
  102.         matches = script.communicate()[0]
  103.         if (matches):
  104.             report['fglrx-loaded'] = matches
  105.     except OSError:
  106.         pass
  107.  
  108.     try:
  109.         script = subprocess.Popen(['xrandr', '--verbose'], stdout=subprocess.PIPE)
  110.         report['Xrandr'] = script.communicate()[0]
  111.     except OSError:
  112.         pass
  113.  
  114.     try:
  115.         monitors_config = os.path.join(os.environ['HOME'], '.config/monitors.xml')
  116.         report['monitors.xml']  = open(monitors_config).read()
  117.     except IOError:
  118.         pass
  119.  
  120.     try:
  121.         script = subprocess.Popen(['xdpyinfo'], stdout=subprocess.PIPE)
  122.         report['xdpyinfo'] = script.communicate()[0]
  123.     except OSError:
  124.         pass
  125.  
  126.     try:
  127.         script = subprocess.Popen(['glxinfo'], stdout=subprocess.PIPE)
  128.         report['glxinfo'] = script.communicate()[0]
  129.     except OSError:
  130.         pass
  131.  
  132.     try:
  133.         script = subprocess.Popen(['setxkbmap', '-print'], stdout=subprocess.PIPE)
  134.         report['setxkbmap'] = script.communicate()[0]
  135.     except OSError:
  136.         pass
  137.  
  138.     try:
  139.         script = subprocess.Popen(['xkbcomp', ':0', '-w0', '-'], stdout=subprocess.PIPE)
  140.         report['xkbcomp'] = script.communicate()[0]
  141.     except OSError:
  142.         pass
  143.  
  144. ## DEBUGING ##
  145. if __name__ == '__main__':
  146.     report = {}
  147.     add_info(report)
  148.     for key in report:
  149.         print '[%s]\n%s' % (key, report[key])
  150.